<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/html">

<head>

    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    

    <title>精研 3.0 - FooTable</title>
    <meta name="keywords" content="H+后台主题,后台bootstrap框架,会员中心主题,后台HTML,响应式后台">
    <meta name="description" content="H+是一个完全响应式，基于Bootstrap3最新版本开发的扁平化主题，她采用了主流的左右两栏式布局，使用了Html5+CSS3等现代技术">

    <link rel="shortcut icon" href="favicon.ico"> <link href="/css/bootstrap.min.css?v=3.3.5" rel="stylesheet">
    <link href="/css/font-awesome.min.css?v=4.4.0" rel="stylesheet">

    <link href="/css/animate.min.css" rel="stylesheet">
    <link href="/css/style.min.css?v=4.0.0" rel="stylesheet"><base target="_blank">
    <!-- Sweet Alert -->
    <link href="/css/plugins/sweetalert/sweetalert.css" rel="stylesheet">
    <!-- 弹窗-->
    <script src="../../tanchuan/js/jquery-2.0.0.min.js"></script>
    <link href="../../tanchuan/css/displaystyle.css" rel="stylesheet" />
    <script src="../../tanchuan/js/syntaxhighlighter_3.0.83/shCore.js"></script>
    <script src="../../tanchuan/js/syntaxhighlighter_3.0.83/shBrushJScript.js"></script>
    <link href="../../tanchuan/js/syntaxhighlighter_3.0.83/styles/shCoreRDark.css" rel="stylesheet" />
    <script src="../../tanchuan/js/NZ-Plugin/Js/NZ-Window.min.js"></script>
    <link href="../../tanchuan/js/NZ-Plugin/Css/NZ-Window.min.css" rel="stylesheet" />
    <script src="../../tanchuan/js/NZ-Plugin/Js/NZ-Drag.min.js"></script>
</head>

<body class="gray-bg">
    <div class="wrapper wrapper-content animated fadeInRight">

            <div class="row">
                <div class="col-sm-12">
                    <div class="ibox float-e-margins">
                        <div class="ibox-title">
                            <h3>自选</h3>
                            <br/>
                            <form id="uploadForm" enctype="multipart/form-data">
                                <div class="input-group mb-3">
                                    <!-- 支持多选的文件上传控件 -->
                                    <input type="file"
                                           id="fileInput"
                                           name="files[]"
                                           class="form-control"
                                           required
                                           multiple> <!-- 添加 multiple 属性 -->
                                </div>

                                <div class="input-group">
                                    <!-- 用户名输入 -->
                                    <input type="text"
                                           id="username"
                                           name="username"
                                           placeholder="请输入用户名"
                                           class="form-control"
                                           required>
                                    <!-- 提交按钮 -->
                                    <span class="input-group-btn">
                                    <button type="submit" class="btn btn-primary">
                                        <i class="fa fa-upload"></i> 上传文件
                                    </button>
                                </span>
                                </div>
                            </form>
                        </div>
                        <br class="ibox-content">

                            <table class="footable table table-stripped toggle-arrow-tiny" data-page-size="100">
                                <thead>
                                <tr>
                                    <th data-toggle="true">解析类型</th>
                                    <th style="font-family:arial;font-size:15px;">地址</th>
                                    <th>操作</th>
                                </tr>
                                </thead>
                                <tbody>
                                    <tr class="gradeX" th:each="tag,resultStat:${nameList}" >
                                        <td th:text="${tag.name}"  style="font-family:arial;font-size:20px;"></td>
                                        <td th:text="${tag.parentUrl}"  style="font-family:arial;font-size:20px;"></td>

                                        <td>
                                            <a th:id="${tag.name}" onclick="showTag(this)" > <i class="badge badge-warning">查看详情</i> </a>
                                        </td>
                                    </tr>
                                </tbody>
                                <tfoot>
                                <tr>
                                    <td colspan="5">
                                        <ul class="pagination pull-right"></ul>
                                    </td>
                                </tr>
                                </tfoot>
                            </table>

                        </div>
                    </div>
                </div>
            </div>
    </div>
<!--    <script src="/js/jquery.min.js?v=2.1.4"></script>-->
<!--    <script src="/js/bootstrap.min.js?v=3.3.5"></script>-->
    <script src="/js/plugins/footable/footable.all.min.js"></script>
<!--    <script src="/js/content.min.js?v=1.0.0"></script>-->

    <!--    <script src="/js/jquery.min.js?v=2.1.4"></script>-->
    <script src="/js/bootstrap.min.js?v=3.3.5"></script>
    <script src="/js/plugins/sparkline/jquery.sparkline.min.js"></script>
    <script src="/js/plugins/peity/jquery.peity.min.js"></script>
    <script src="/js/content.min.js?v=1.0.0"></script>
    <script src="/js/demo/peity-demo.min.js"></script>
    <script src="/js/plugins/gritter/jquery.gritter.min.js"></script>
    <script src="/js/plugins/sweetalert/sweetalert.min.js"></script>
    <script>
        $(document).ready(function(){$(".footable").footable();$(".footable2").footable()});
    </script>
    <script>


        /**
         * 添加
         * */
        function handleClick() {
            var code = $("#codeName").val();
            if (code == null || code == "" ) {
                    swal({title: "请输入地址", text: ""});
            } else {

                $.ajax({
                    url: '/ajaxRequestEbay',
                    type: "get",
                    data: {"code": code},
                    success: function (data) {
                        var code1 = $.parseJSON(data);
                        var code = code1.code;
                        var desc = prompt("请输入备注描述：", code1.gpname);
                        $("#addCode").val(code);
                        $("#addDesc").val(desc);
                        handleClickAjax(code, desc);
                    },
                    error: function (XMLHttpRequest, textStatus, errorThrown) {
                        swal({title: "查询失败，请检查股票代码！", text: ""});

                    },
                });
            }
        }

        /**
         * 添加
         * @param code
         * @param desc
         */
        function handleClickAjax(code, desc) {
            $.ajax({
                url: '/ebay/ebaySearchByTypeService',
                type: "get",
                data: {"goodsUrl": code, "name": desc},
                success: function (data) {
                    window.location.reload();
                },
                error: function (XMLHttpRequest, textStatus, errorThrown) {
                    swal({title: "查询失败，请检查股票代码！", text: ""});
                },
            });
        }

        function showTag(url){
             url ="/ebay/detail/?name="+url.id;
            $.NZ_Window.show({
                url: url,
                width: 1500,
                height: 1000,
                operate: {
                    btn_Close: true, //关闭按钮
                    btn_Max: true, //最大化按钮
                    btn_Refresh: true, //刷新按钮
                    btn_NewWindow: true, //新窗口按钮
                    resize: true //调整窗口大小按钮
                }
            });
        }



        document.getElementById('uploadForm').addEventListener('submit', async (e) => {
            e.preventDefault();

            const formData = new FormData();
            // 获取所有选中的文件
            const files = document.getElementById('fileInput').files;

            // 添加所有文件到表单数据
            for (let i = 0; i < files.length; i++) {
                formData.append('files', files[i]); // 注意保持与后端一致的参数名
            }
            formData.append('username', document.getElementById('username').value);

            try {
                const response = await fetch('/ebay/ebayApiSearch', {
                    method: 'POST',
                    body: formData
                });

                const result = await response.json();
                if (response.ok) {
                    alert(`上传成功！共处理 ${result.total} 个文件（成功 ${result.success} 个）`);
                } else {
                    alert(`上传失败：${result.message}`);
                }
            } catch (error) {
                console.error('请求错误:', error);
                alert('网络请求异常，请检查控制台');
            }
        });
    </script>
</body>

</html>